<template id="home-content">
  <div class="container">
    <div class="topology">
      <dv-border-box-12>
        <topology @node-click="handleNodeClick" />
      </dv-border-box-12>
    </div>
    <div class="details">
      <dv-border-box-12>
        <node-details ref="nodeDetails" :name="selectedNodeName" v-if="selectedNodeName" />
        <div v-else>
          <analyse-topology-copy />
        </div>
      </dv-border-box-12>
    </div>
  </div>
  <router-view />
</template>

<script>
import Topology from "@/components/echarts/topology/ClickTopology.vue";
import NodeDetails from "@/components/echarts/node/Graph.vue"; // 示例动态组件
import AnalyseTopologyCopy from "@/components/echarts/topology/AnalyseTopologyCopy.vue";

export default {
  name: "Predict",
  components: {
    Topology,
    NodeDetails,
    AnalyseTopologyCopy,
  },
  data() {
    return {
      selectedNodeName: "", // 当前选中的节点名称
      detailComponent: null, // 动态加载的详情组件
    };
  },
  methods: {
    handleNodeClick(nodeName) {
      // 处理拓扑图点击事件
      this.selectedNodeName = nodeName.toLowerCase();
      console.log("Selected Node:", this.selectedNodeName);

      if (this.selectedNodeName === "nwdaf") {
        console.log("Selected Node:", this.selectedNodeName);
        this.selectedNodeName = "";
      }

      // 通过ref获取NodeDetails组件并调用刷新方法
      if (this.$refs.nodeDetails) {
        this.$refs.nodeDetails.refreshCharts();
      }
    },
  },
};
</script>

<style scoped>
.container {
  display: flex;
  height: 80%;
  width: 100%;
  justify-content: center;
  margin-top: 20px;
  font-size: 30px;
}

.topology {
  width: 100%;
  flex: 3;
}

.details {
  width: 100%;
  flex: 4;
}

.placeholder {
  display: flex;
  justify-content: center; /* 水平居中 */
  align-items: center; /* 垂直居中 */
  height: 100%; /* 填充父容器 */
  font-size: 40px; /* 可以根据需要调整字体大小 */
  font-weight: bold;
  text-align: center;
}
</style>
